package cn.itlaobing.springbootdemo.web.listener;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class ApplicationContextListener implements ServletContextListener {
    Log log= LogFactory.getLog(this.getClass());
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        //当上下文对象（应用程序创建的时候触发该事件）
        ServletContext app= sce.getServletContext();
        app.setAttribute("ctx",app.getContextPath());
    }
    @Override
    public void contextDestroyed(ServletContextEvent sce) {

    }
}

